<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('缓存线管理')"/>
    <style>
        [v-cloak] {
            display: none;
        }
        .tag {
            display: inline-block;
            padding: 0 5px;
            line-height: 22px;
            color: #FFFFFF;
            border-radius: 3px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li v-if="checkedSearch.indexOf('缓存线编码') != -1">
                            缓存线编码：<input type="text" name="shelfCode"/>
                        </li>
                        <li v-if="checkedSearch.indexOf('缓存线状态') != -1">
                            缓存线状态：
                            <select name="state">
                                <option value="">全部</option>
                                <option value="1">OK</option>
                                <option value="-1">NG</option>
                            </select>
                        </li>
                        <li v-if="checkedSearch.indexOf('单晶PN型') != -1">
                            单晶PN型：
                            <select name="materialPN">
                                <option value="">全部</option>
                                <option value="P">P</option>
                                <option value="N">N</option>
                            </select>
                        </li>
                        <li v-if="checkedSearch.indexOf('客户等级') != -1">
                            客户等级：
                            <select name="materialCategory">
                                <option value="">全部</option>
                                <option value="A">A</option>
                                <option value="A+H">A+H</option>
                                <option value="A-">A-</option>
                            </select>
                        </li>
                        <li v-if="checkedSearch.indexOf('单晶规格') != -1">
                            单晶规格：
                            <select name="spec">
                                <option value="">全部</option>
                                <option value="G12">G12</option>
                                <option value="M6">M6</option>
                            </select>
                        </li>
                        <li v-if="checkedSearch.indexOf('拼棒类型') != -1">
                            拼棒类型：
                            <select name="assemblyType">
                                <option value="">全部</option>
                                <option value="1">整棒</option>
                                <option value="2">二拼</option>
                                <option value="3">三拼</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            <a class="btn btn-success btn-rounded btn-sm" @click="moreSearch()"><i class="fa fa-edit"></i>&nbsp;更多</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <el-dialog title="搜索条件" width="200px" :visible.sync="showMore">
            <el-row>
                <el-col :span="24">
                    <el-checkbox style="margin-left: 28px" :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
                    <el-checkbox-group v-model="checkedSearch" @change="handleCheckedSearchChange">
                        <el-checkbox style="display: block;margin-left: 28px" v-for="item in searches" :label="item" :key="item" v-cloak>{{item}}</el-checkbox>
                    </el-checkbox-group>
                </el-col>
            </el-row>
        </el-dialog>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ShelfPlan:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="ShelfPlan:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<div th:include="include :: footer"></div>
<script th:src="@{/wms/js/moreSearch.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ShelfPlan:edit')}]];
    var prefix = ctx + "ShelfPlan";

    const searchOptions = ['缓存线编码', '缓存线状态', '单晶PN型', '客户等级', '单晶规格', '拼棒类型'];

    var app = new Vue({
        el: '.container-div',
        data: {
            showMore: false,
            checkAll: false,
            checkedSearch: ['缓存线编码', '缓存线状态'],
            searches: searchOptions,
            isIndeterminate: true
        }
    })

    $(function() {
        var options = {
            url: prefix + "/findList",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            modalName: "缓存线管理",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'shelfId',
                    title: '缓存线ID',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'shelfCode',
                    title: '缓存线编码',
                    align: 'center'
                },
                {
                    field: 'state',
                    title: '缓存线状态',
                    align: 'center',
                    formatter: function(value, row, index){
                        var actions = [];
                        if(value == 1){
                            actions.push("<span style='display: inline-block;padding: 0 5px;line-height: 22px;color: #FFFFFF;background-color: #1ab394;border-radius: 3px'>OK</span>");
                        }else if(value == -1){
                            actions.push("<span style='display: inline-block;padding: 0 5px;line-height: 22px;color: #FFFFFF;background-color: #ed5565;border-radius: 3px'>NG</span>");
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'memo',
                    title: '备注',
                    align: 'center',
                    formatter: function(value, item, index){
                        if(value == null || value == ''){
                            return '无'
                        }else{
                            return value;
                        }
                    }
                },
                {
                    field: 'materialPN',
                    title: '单晶PN型',
                    align: 'center'
                },
                {
                    field: 'materialCategory',
                    title: '客户等级',
                    align: 'center'
                },
                {
                    field: 'spec',
                    title: '单晶规格',
                    align: 'center'
                },
                {
                    field: 'assemblyType',
                    title: '拼棒类型',
                    align: 'center',
                    formatter: function(value, item, index){
                        var actions = [];
                        if(value == 1){
                            actions.push("<span class='tag' style='background-color: #fcb529'>整棒</span>");
                        }else if(value == 2){
                            actions.push("<span class='tag' style='background-color: #45ade1'>二拼</span>");
                        }else if(value == 3){
                            actions.push("<span class='tag' style='background-color: #45ade1'>三拼</span>");
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'description',
                    title: 'NG原因',
                    align: 'center'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    align: 'center',
                    formatter: function(value, item, index){
                        if(value == null){
                            return '-';
                        }else{
                            return value.slice(0, 19);
                        }
                    }
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    align: 'center',
                    formatter: function(value, item, index){
                        if(value == null){
                            return '-';
                        }else{
                            return value.slice(0, 19);
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index){
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a>');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
